/**
 * \file screenpig/window.c
 * \date 01-17-2010
 * \author Davide Gessa
 */
#include "include/render.h"
#include "include/window.h"


/**
 * Crea una finestra
 */
window_t *window_new(char *label, uint32_t x, uint32_t y, uint32_t size_x, uint32_t size_y)
{
	window_t *win = (window_t *) malloc(sizeof(window_t));
	
	strcpy(win->label, label);
	win->x = x;
	win->y = y;
	win->size_x = size_x;
	win->size_y = size_y;
	win->if_decorated = 1;
	win->if_updated = 1;
	
	win->next = window_list;
	window_list = win;
	return win;
}


/**
 * Elimina una finestra
 */
void window_delete(window_t *win)
{
	
	
}



/**
 * Renderizza una finestra
 */
void window_render(window_t *win)
{
	if(win->if_updated)
	{
		//render_draw_rect(win->x, win->y - 14, win->x + win->size_x, win->y, 0x00B8F5);
		render_draw_rect_bordered(win->x - 1, win->y - 14, win->x + win->size_x + 1, win->y, 1, 0x0, 0x008AB8);
		render_write_text(16, win->label, 0, win->x + 3, win->y - 11);
		render_write_text(16, "_x", 0, win->x + win->size_x - 17, win->y - 11);
		render_draw_rect_bordered(win->x - 1, win->y, win->x + win->size_x + 1, win->y + win->size_y + 1, 1, 0x0, 0xE0E0E0);
		//render_draw_rect(win->x + win->size_x - 5, win->y + win->size_y - 5, win->x + win->size_x, win->y + win->size_y, 0x0);	
		
		//render_draw_rect_fill(win->x, win->y + 14, win->x + win->size_x, win->y + win->size_y , 0x0);
		//render_write_text(16, "/dev$ ", 0xFFFFFFFFF, win->x + 2, win->y + 16);
		win->if_updated = 0;
	}
}
